#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<string ,int >a;
int n;
string s1,s2;
int main()
{
	freopen("network.in","r",stdin);
	freopen("network.out","w",stdout);
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>s1>>s2;
		if(s1=="Server")
		{
			if(a[s2]!=0) 
			{
				cout<<"FAIL";
			}
			else
			{
				a[s2]=i;
				cout<<"OK";
			}
			
		}
		if(s1=="Client")
		{
			if(a[s2]!=0)
			{
				cout<<a[s2];
			}
			else cout<<"FAIL";
		}
		cout<<endl;
	}
	
	return 0;
}
